| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 111 | 
| Lines | 111 | 
| Ratio | 100 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /*!  | 
            ||
| 12 | describe('create 16-bit wave files from scratch', function() { | 
            ||
| 13 | |||
| 14 |     let wavefile = require('../../index.js'); | 
            ||
| 15 | let wav = new wavefile.WaveFile();  | 
            ||
| 16 | wav.fromScratch(1, 48000, '16', [0, 1, -32768, 32767]);  | 
            ||
| 17 | |||
| 18 |     let fs = require('fs'); | 
            ||
| 19 |     fs.writeFileSync("./test/files/out/16-bit-48kHz-mono-fromScratch.wav", wav.toBytes()); | 
            ||
| 20 | |||
| 21 |     it('chunkId should be "RIFF"', function() { | 
            ||
| 22 | assert.equal(wav.chunkId, "RIFF");  | 
            ||
| 23 | });  | 
            ||
| 24 | |||
| 25 |     it('format should be "WAVE"', function() { | 
            ||
| 26 | assert.equal(wav.format, "WAVE");  | 
            ||
| 27 | });  | 
            ||
| 28 | |||
| 29 |     it('subChunk1Id should be "fmt "', function() { | 
            ||
| 30 | assert.equal(wav.subChunk1Id, "fmt ");  | 
            ||
| 31 | });  | 
            ||
| 32 | |||
| 33 |     it('subChunk1Size should be 16', function() { | 
            ||
| 34 | assert.equal(wav.subChunk1Size, 16);  | 
            ||
| 35 | });  | 
            ||
| 36 | |||
| 37 |     it('audioFormat should be 1', function() { | 
            ||
| 38 | assert.equal(wav.audioFormat, 1);  | 
            ||
| 39 | });  | 
            ||
| 40 | |||
| 41 |     it('numChannels should be 1', function() { | 
            ||
| 42 | assert.equal(wav.numChannels, 1);  | 
            ||
| 43 | });  | 
            ||
| 44 | |||
| 45 |     it('sampleRate should be 48000', function() { | 
            ||
| 46 | assert.equal(wav.sampleRate, 48000);  | 
            ||
| 47 | });  | 
            ||
| 48 | |||
| 49 |     it('byteRate should be 96000', function() { | 
            ||
| 50 | assert.equal(wav.byteRate, 96000);  | 
            ||
| 51 | });  | 
            ||
| 52 | |||
| 53 |     it('blockAlign should be 2', function() { | 
            ||
| 54 | assert.equal(wav.blockAlign, 2);  | 
            ||
| 55 | });  | 
            ||
| 56 | |||
| 57 |     it('bitsPerSample should be 16', function() { | 
            ||
| 58 | assert.equal(wav.bitsPerSample, 16);  | 
            ||
| 59 | });  | 
            ||
| 60 | |||
| 61 |     it('subChunk2Id should be "data"', function() { | 
            ||
| 62 | assert.equal(wav.subChunk2Id, "data");  | 
            ||
| 63 | });  | 
            ||
| 64 | |||
| 65 |     it('subChunk2Size should be 8', function() { | 
            ||
| 66 | assert.equal(wav.subChunk2Size, 8);  | 
            ||
| 67 | });  | 
            ||
| 68 | |||
| 69 |     it('samples_ should be the same as the args', function() { | 
            ||
| 70 | assert.deepEqual(wav.samples_, [0, 1, -32768, 32767]);  | 
            ||
| 71 | });  | 
            ||
| 72 | |||
| 73 |     it('bitDepth_ should be "16"', function() { | 
            ||
| 74 | assert.equal(wav.bitDepth_, "16");  | 
            ||
| 75 | });  | 
            ||
| 76 | |||
| 77 | /*  | 
            ||
| 78 |     it('should return a 16-bit wave file', function() { | 
            ||
| 79 | let wav = rw64.writeWavBytes(1, 48000, '16',  | 
            ||
| 80 | [0, 1, -32768, 32767]);  | 
            ||
| 81 | let wavRead = rw64.readWavBytes(wav);  | 
            ||
| 82 | |||
| 83 | assert.equal(wavRead.audioFormat, 1);  | 
            ||
| 84 | assert.equal(wavRead.numChannels, 1);  | 
            ||
| 85 | assert.equal(wavRead.blockAlign, 2);  | 
            ||
| 86 | assert.equal(wavRead.sampleRate, 48000);  | 
            ||
| 87 | assert.equal(wavRead.bitsPerSample, 16);  | 
            ||
| 88 | assert.deepEqual(wavRead.samples, [0, 1, -32768, 32767]);  | 
            ||
| 89 | });  | 
            ||
| 90 | |||
| 91 |     it('should return a 16-bit wave file with a odd number of samples', | 
            ||
| 92 |             function() { | 
            ||
| 93 | let wav = rw64.writeWavBytes(1, 48000, '16',  | 
            ||
| 94 | [0, 1, -32768, 32767, 4]);  | 
            ||
| 95 | let wavRead = rw64.readWavBytes(wav);  | 
            ||
| 96 | |||
| 97 | assert.equal(wavRead.audioFormat, 1);  | 
            ||
| 98 | assert.equal(wavRead.numChannels, 1);  | 
            ||
| 99 | assert.equal(wavRead.blockAlign, 2);  | 
            ||
| 100 | assert.equal(wavRead.sampleRate, 48000);  | 
            ||
| 101 | assert.equal(wavRead.bitsPerSample, 16);  | 
            ||
| 102 | assert.deepEqual(wavRead.samples, [0, 1, -32768, 32767, 4]);  | 
            ||
| 103 | });  | 
            ||
| 104 | |||
| 105 |     it('should write a 16-bit stereo wav file', function() { | 
            ||
| 106 | let channels = [  | 
            ||
| 107 | [0,1,2],  | 
            ||
| 108 | [0,1,2]  | 
            ||
| 109 | ];  | 
            ||
| 110 | let samples = rw64.interleave(channels);  | 
            ||
| 111 | let wav = rw64.writeWavBytes(2, 44100, '16', samples);  | 
            ||
| 112 | let read = rw64.readWavBytes(wav);  | 
            ||
| 113 | |||
| 114 | assert.equal(read.subChunk1Size, 16);  | 
            ||
| 115 | assert.equal(read.audioFormat, 1);  | 
            ||
| 116 | assert.equal(read.numChannels, 2);  | 
            ||
| 117 | assert.equal(read.sampleRate, 44100);  | 
            ||
| 118 | assert.equal(read.blockAlign, 4);  | 
            ||
| 119 | assert.equal(read.bitsPerSample, 16);  | 
            ||
| 120 | });  | 
            ||
| 121 | */  | 
            ||
| 122 | });  | 
            ||
| 123 |